home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / WAIS / next-ui / AssocTableCell.m < prev    next >
Encoding:
Text File  |  1992-02-03  |  2.5 KB  |  115 lines

  1. // AssocTableCell.m
  2. //
  3. // Free software created 1 Feb 1992
  4. // by Paul Burchard <burchard@math.utah.edu>.
  5.  
  6. #import "AssocTableCell.h"
  7. #import <appkit/appkit.h>
  8.  
  9. @implementation AssocTableCell
  10.  
  11. - initTextCell:(const char *)aString
  12. {
  13.     [super initTextCell:aString];
  14.     assocField = [[TextFieldCell alloc] initTextCell:""];
  15.     assocSize = 0.20;
  16.     assocGray = NX_DKGRAY;
  17.     [assocField setTextGray:assocGray];
  18.     return self;
  19. }
  20.  
  21. - free
  22. {
  23.     [assocField free];
  24.     return [super free];
  25. }
  26.  
  27. - drawInside:(const NXRect *)cellFrame inView:controlView
  28. {
  29.     NXRect assocFrame, textFrame;
  30.     float x, y, h, w;
  31.     id rtn;
  32.     
  33.     // Compute subcell rects.
  34.     x = NX_X(cellFrame); y = NX_Y(cellFrame);
  35.     w = NX_WIDTH(cellFrame); h = NX_HEIGHT(cellFrame);
  36.     NX_X(&assocFrame) = x;            NX_Y(&assocFrame) = y;
  37.     NX_WIDTH(&assocFrame) = assocSize*w;    NX_HEIGHT(&assocFrame) = h;
  38.     NX_X(&textFrame) = x + assocSize*w;        NX_Y(&textFrame) = y;
  39.     NX_WIDTH(&textFrame) = (1-assocSize)*w;    NX_HEIGHT(&textFrame) = h;
  40.     
  41.     // Draw subcells.
  42.     rtn = [super drawInside:&textFrame inView:controlView];
  43.     [assocField drawSelf:&assocFrame inView:controlView];
  44.     [assocField highlight:&assocFrame inView:controlView lit:[self isHighlighted]];
  45.     return rtn;
  46. }
  47.  
  48. - setBackgroundColor:(NXColor)Colorvalue
  49. {
  50.     [assocField setBackgroundColor:Colorvalue];
  51.     return [super setBackgroundColor:Colorvalue];
  52. }
  53.  
  54. - setBackgroundGray:(float)value
  55. {
  56.     [assocField setBackgroundGray:value];
  57.     return [super setBackgroundGray:value];
  58. }
  59.  
  60. - setBackgroundTransparent:(BOOL)flag
  61. {
  62.     [assocField setBackgroundTransparent:flag];
  63.     return [super setBackgroundTransparent:flag];
  64. }
  65.  
  66. - setTextAttributes:textObj
  67. {
  68.     [assocField setTextAttributes:textObj];
  69.     [assocField setTextGray:assocGray];
  70.     return [super setTextAttributes:textObj];
  71. }
  72.  
  73. - setAssocStringValue:(const char *)aValue
  74. {
  75.     [assocField setStringValue:aValue];
  76.     [[self controlView] updateCellInside:self];
  77.     return self;
  78. }
  79.  
  80. - (const char *)assocStringValue
  81. {
  82.     return [assocField stringValue];
  83. }
  84.  
  85. - setAssocSize:(float)aValue
  86. {
  87.     assocSize = aValue;
  88.     if(assocSize > 1.0) assocSize = 1.0;
  89.     if(assocSize < 0.0) assocSize = 0.0;
  90.     [[self controlView] updateCellInside:self];
  91.     return self;
  92. }
  93.  
  94. - (float)assocSize
  95. {
  96.     return assocSize;
  97. }
  98.  
  99. - setAssocGray:(float)aValue
  100. {
  101.     assocGray = aValue;
  102.     if(assocGray > 1.0) assocGray = 1.0;
  103.     if(assocGray < 0.0) assocGray = 0.0;
  104.     [assocField setTextGray:assocGray];
  105.     [[self controlView] updateCellInside:self];
  106.     return self;
  107. }
  108.  
  109. - (float)assocGray
  110. {
  111.     return assocGray;
  112. }
  113.  
  114. @end
  115.